<!-- HTML header for doxygen 1.8.6-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.13"/>
<title>OpenCV: Training Model Analysis</title>
<link href="../../opencv.ico" rel="shortcut icon" type="image/x-icon" />
<link href="../../tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="../../jquery.js"></script>
<script type="text/javascript" src="../../dynsections.js"></script>
<script type="text/javascript" src="../../tutorial-utils.js"></script>
<link href="../../search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="../../search/searchdata.js"></script>
<script type="text/javascript" src="../../search/search.js"></script>
<script type="text/x-mathjax-config">
  MathJax.Hub.Config({
    extensions: ["tex2jax.js", "TeX/AMSmath.js", "TeX/AMSsymbols.js"],
    jax: ["input/TeX","output/HTML-CSS"],
});
//<![CDATA[
MathJax.Hub.Config(
{
  TeX: {
      Macros: {
          matTT: [ "\\[ \\left|\\begin{array}{ccc} #1 & #2 & #3\\\\ #4 & #5 & #6\\\\ #7 & #8 & #9 \\end{array}\\right| \\]", 9],
          fork: ["\\left\\{ \\begin{array}{l l} #1 & \\mbox{#2}\\\\ #3 & \\mbox{#4}\\\\ \\end{array} \\right.", 4],
          forkthree: ["\\left\\{ \\begin{array}{l l} #1 & \\mbox{#2}\\\\ #3 & \\mbox{#4}\\\\ #5 & \\mbox{#6}\\\\ \\end{array} \\right.", 6],
          forkfour: ["\\left\\{ \\begin{array}{l l} #1 & \\mbox{#2}\\\\ #3 & \\mbox{#4}\\\\ #5 & \\mbox{#6}\\\\ #7 & \\mbox{#8}\\\\ \\end{array} \\right.", 8],
          vecthree: ["\\begin{bmatrix} #1\\\\ #2\\\\ #3 \\end{bmatrix}", 3],
          vecthreethree: ["\\begin{bmatrix} #1 & #2 & #3\\\\ #4 & #5 & #6\\\\ #7 & #8 & #9 \\end{bmatrix}", 9],
          cameramatrix: ["#1 = \\begin{bmatrix} f_x & 0 & c_x\\\\ 0 & f_y & c_y\\\\ 0 & 0 & 1 \\end{bmatrix}", 1],
          distcoeffs: ["(k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6 [, s_1, s_2, s_3, s_4[, \\tau_x, \\tau_y]]]]) \\text{ of 4, 5, 8, 12 or 14 elements}"],
          distcoeffsfisheye: ["(k_1, k_2, k_3, k_4)"],
          hdotsfor: ["\\dots", 1],
          mathbbm: ["\\mathbb{#1}", 1],
          bordermatrix: ["\\matrix{#1}", 1]
      }
  }
}
);
//]]>
</script><script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js"></script>
<link href="../../doxygen.css" rel="stylesheet" type="text/css" />
<link href="../../stylesheet.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<!--#include virtual="/google-search.html"-->
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="../../opencv-logo-small.png"/></td>
  <td style="padding-left: 0.5em;">
   <div id="projectname">OpenCV
   &#160;<span id="projectnumber">4.5.2</span>
   </div>
   <div id="projectbrief">Open Source Computer Vision</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.13 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "../../search",false,'Search');
</script>
<script type="text/javascript" src="../../menudata.js"></script>
<script type="text/javascript" src="../../menu.js"></script>
<script type="text/javascript">
$(function() {
  initMenu('../../',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="../../d3/d81/tutorial_contrib_root.html">Tutorials for contrib modules</a></li><li class="navelem"><a class="el" href="../../d2/d42/tutorial_table_of_content_cnn_3dobj.html">CNN for 3D Object Classification and Pose Estimation</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="headertitle">
<div class="title">Training Model Analysis </div>  </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><h2>Goal </h2>
<p>In this tutorial you will learn how to</p>
<ul>
<li>Extract feature from particular image.</li>
<li>Have a meaningful comparation on the extracted feature.</li>
</ul>
<h2>Code </h2>
<div class="fragment"><div class="line"><span class="comment">/*</span></div><div class="line"><span class="comment"> * Software License Agreement (BSD License)</span></div><div class="line"><span class="comment"> *</span></div><div class="line"><span class="comment"> *  Copyright (c) 2009, Willow Garage, Inc.</span></div><div class="line"><span class="comment"> *  All rights reserved.</span></div><div class="line"><span class="comment"> *</span></div><div class="line"><span class="comment"> *  Redistribution and use in source and binary forms, with or without</span></div><div class="line"><span class="comment"> *  modification, are permitted provided that the following conditions</span></div><div class="line"><span class="comment"> *  are met:</span></div><div class="line"><span class="comment"> *</span></div><div class="line"><span class="comment"> *   * Redistributions of source code must retain the above copyright</span></div><div class="line"><span class="comment"> *     notice, this list of conditions and the following disclaimer.</span></div><div class="line"><span class="comment"> *   * Redistributions in binary form must reproduce the above</span></div><div class="line"><span class="comment"> *     copyright notice, this list of conditions and the following</span></div><div class="line"><span class="comment"> *     disclaimer in the documentation and/or other materials provided</span></div><div class="line"><span class="comment"> *     with the distribution.</span></div><div class="line"><span class="comment"> *   * Neither the name of Willow Garage, Inc. nor the names of its</span></div><div class="line"><span class="comment"> *     contributors may be used to endorse or promote products derived</span></div><div class="line"><span class="comment"> *     from this software without specific prior written permission.</span></div><div class="line"><span class="comment"> *</span></div><div class="line"><span class="comment"> *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS</span></div><div class="line"><span class="comment"> *  &quot;AS IS&quot; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT</span></div><div class="line"><span class="comment"> *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS</span></div><div class="line"><span class="comment"> *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE</span></div><div class="line"><span class="comment"> *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,</span></div><div class="line"><span class="comment"> *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,</span></div><div class="line"><span class="comment"> *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;</span></div><div class="line"><span class="comment"> *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER</span></div><div class="line"><span class="comment"> *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT</span></div><div class="line"><span class="comment"> *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN</span></div><div class="line"><span class="comment"> *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE</span></div><div class="line"><span class="comment"> *  POSSIBILITY OF SUCH DAMAGE.</span></div><div class="line"><span class="comment"> *</span></div><div class="line"><span class="comment"> */</span></div><div class="line"><span class="preprocessor">#include &lt;iostream&gt;</span></div><div class="line"><span class="preprocessor">#include &quot;<a class="code" href="../../d1/d4f/imgproc_2include_2opencv2_2imgproc_8hpp.html">opencv2/imgproc.hpp</a>&quot;</span></div><div class="line"><span class="preprocessor">#include &quot;<a class="code" href="../../de/d45/cnn__3dobj_8hpp.html">opencv2/cnn_3dobj.hpp</a>&quot;</span></div><div class="line"><span class="keyword">using namespace </span><a class="code" href="../../d2/d75/namespacecv.html">cv</a>;</div><div class="line"><span class="keyword">using namespace </span><a class="code" href="../../d9/d57/namespacecv_1_1cnn__3dobj.html">cv::cnn_3dobj</a>;</div><div class="line"></div><div class="line"><span class="keywordtype">int</span> main(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span>** argv)</div><div class="line">{</div><div class="line">    <span class="keyword">const</span> <a class="code" href="../../dc/d84/group__core__basic.html#ga1f6634802eeadfd7245bc75cf3e216c2">String</a> keys = <span class="stringliteral">&quot;{help | | this demo will have an analysis on the trained model, it will print information about whether the model is suit for set different classes apart and also discriminant on object pose at the same time.}&quot;</span></div><div class="line"><span class="stringliteral">&quot;{caffemodel | ../../testdata/cv/3d_triplet_iter_30000.caffemodel | caffe model for feature exrtaction.}&quot;</span></div><div class="line"><span class="stringliteral">&quot;{network_forIMG | ../../testdata/cv/3d_triplet_testIMG.prototxt | Network definition file used for extracting feature from a single image and making a classification}&quot;</span></div><div class="line"><span class="stringliteral">&quot;{mean_file | no | The mean file generated by Caffe from all gallery images, this could be used for mean value substraction from all images. If you want to use the mean file, you can set this as ../data/images_mean/triplet_mean.binaryproto.}&quot;</span></div><div class="line"><span class="stringliteral">&quot;{target_img | ../data/images_all/4_78.png | Path of image in reference.}&quot;</span></div><div class="line"><span class="stringliteral">&quot;{ref_img1 | ../data/images_all/4_79.png | Path of closest image.}&quot;</span></div><div class="line"><span class="stringliteral">&quot;{ref_img2 | ../data/images_all/4_87.png | Path of less closer image in the same class with reference image.}&quot;</span></div><div class="line"><span class="stringliteral">&quot;{ref_img3 | ../data/images_all/3_78.png | Path of image with the same pose in another class.}&quot;</span></div><div class="line"><span class="stringliteral">&quot;{feature_blob | feat | Name of layer which will represent as the feature, in this network, ip1 or feat is well.}&quot;</span></div><div class="line"><span class="stringliteral">&quot;{device | CPU | device}&quot;</span></div><div class="line"><span class="stringliteral">&quot;{dev_id | 0 | dev_id}&quot;</span>;</div><div class="line">    <span class="comment">/* Get parameters from comand line. */</span></div><div class="line">    <a class="code" href="../../d0/d2e/classcv_1_1CommandLineParser.html">cv::CommandLineParser</a> parser(argc, argv, keys);</div><div class="line">    parser.about(<span class="stringliteral">&quot;Demo for object data classification and pose estimation&quot;</span>);</div><div class="line">    <span class="keywordflow">if</span> (parser.has(<span class="stringliteral">&quot;help&quot;</span>))</div><div class="line">    {</div><div class="line">        parser.printMessage();</div><div class="line">        <span class="keywordflow">return</span> 0;</div><div class="line">    }</div><div class="line">    <a class="code" href="../../dc/d84/group__core__basic.html#ga1f6634802eeadfd7245bc75cf3e216c2">String</a> caffemodel = parser.get&lt;<a class="code" href="../../dc/d84/group__core__basic.html#ga1f6634802eeadfd7245bc75cf3e216c2">String</a>&gt;(<span class="stringliteral">&quot;caffemodel&quot;</span>);</div><div class="line">    <a class="code" href="../../dc/d84/group__core__basic.html#ga1f6634802eeadfd7245bc75cf3e216c2">String</a> network_forIMG = parser.get&lt;<a class="code" href="../../dc/d84/group__core__basic.html#ga1f6634802eeadfd7245bc75cf3e216c2">String</a>&gt;(<span class="stringliteral">&quot;network_forIMG&quot;</span>);</div><div class="line">    <a class="code" href="../../dc/d84/group__core__basic.html#ga1f6634802eeadfd7245bc75cf3e216c2">String</a> mean_file = parser.get&lt;<a class="code" href="../../dc/d84/group__core__basic.html#ga1f6634802eeadfd7245bc75cf3e216c2">String</a>&gt;(<span class="stringliteral">&quot;mean_file&quot;</span>);</div><div class="line">    <a class="code" href="../../dc/d84/group__core__basic.html#ga1f6634802eeadfd7245bc75cf3e216c2">String</a> target_img = parser.get&lt;<a class="code" href="../../dc/d84/group__core__basic.html#ga1f6634802eeadfd7245bc75cf3e216c2">String</a>&gt;(<span class="stringliteral">&quot;target_img&quot;</span>);</div><div class="line">    <a class="code" href="../../dc/d84/group__core__basic.html#ga1f6634802eeadfd7245bc75cf3e216c2">String</a> ref_img1 = parser.get&lt;<a class="code" href="../../dc/d84/group__core__basic.html#ga1f6634802eeadfd7245bc75cf3e216c2">String</a>&gt;(<span class="stringliteral">&quot;ref_img1&quot;</span>);</div><div class="line">    <a class="code" href="../../dc/d84/group__core__basic.html#ga1f6634802eeadfd7245bc75cf3e216c2">String</a> ref_img2 = parser.get&lt;<a class="code" href="../../dc/d84/group__core__basic.html#ga1f6634802eeadfd7245bc75cf3e216c2">String</a>&gt;(<span class="stringliteral">&quot;ref_img2&quot;</span>);</div><div class="line">    <a class="code" href="../../dc/d84/group__core__basic.html#ga1f6634802eeadfd7245bc75cf3e216c2">String</a> ref_img3 = parser.get&lt;<a class="code" href="../../dc/d84/group__core__basic.html#ga1f6634802eeadfd7245bc75cf3e216c2">String</a>&gt;(<span class="stringliteral">&quot;ref_img3&quot;</span>);</div><div class="line">    <a class="code" href="../../dc/d84/group__core__basic.html#ga1f6634802eeadfd7245bc75cf3e216c2">String</a> feature_blob = parser.get&lt;<a class="code" href="../../dc/d84/group__core__basic.html#ga1f6634802eeadfd7245bc75cf3e216c2">String</a>&gt;(<span class="stringliteral">&quot;feature_blob&quot;</span>);</div><div class="line">    <a class="code" href="../../dc/d84/group__core__basic.html#ga1f6634802eeadfd7245bc75cf3e216c2">String</a> device = parser.get&lt;<a class="code" href="../../dc/d84/group__core__basic.html#ga1f6634802eeadfd7245bc75cf3e216c2">String</a>&gt;(<span class="stringliteral">&quot;device&quot;</span>);</div><div class="line">    <span class="keywordtype">int</span> dev_id = parser.get&lt;<span class="keywordtype">int</span>&gt;(<span class="stringliteral">&quot;dev_id&quot;</span>);</div><div class="line"></div><div class="line">    std::vector&lt;String&gt; ref_img;</div><div class="line">    <span class="comment">/* Sample which is most closest in pose to reference image</span></div><div class="line"><span class="comment">    *and also the same class.</span></div><div class="line"><span class="comment">    */</span></div><div class="line">    ref_img.push_back(ref_img1);</div><div class="line">    <span class="comment">/* Sample which is less closest in pose to reference image</span></div><div class="line"><span class="comment">    *and also the same class.</span></div><div class="line"><span class="comment">    */</span></div><div class="line">    ref_img.push_back(ref_img2);</div><div class="line">    <span class="comment">/* Sample which is very close in pose to reference image</span></div><div class="line"><span class="comment">    *but not the same class.</span></div><div class="line"><span class="comment">    */</span></div><div class="line">    ref_img.push_back(ref_img3);</div><div class="line"></div><div class="line">    <span class="comment">/* Initialize a net work with Device. */</span></div><div class="line">    <a class="code" href="../../d7/d8d/classcv_1_1cnn__3dobj_1_1descriptorExtractor.html">cv::cnn_3dobj::descriptorExtractor</a> descriptor(device, dev_id);</div><div class="line">    <span class="comment">/* Load net with the caffe trained net work parameter and structure. */</span></div><div class="line">    <span class="keywordflow">if</span> (strcmp(mean_file.c_str(), <span class="stringliteral">&quot;no&quot;</span>) == 0)</div><div class="line">        descriptor.loadNet(network_forIMG, caffemodel);</div><div class="line">    <span class="keywordflow">else</span></div><div class="line">        descriptor.loadNet(network_forIMG, caffemodel, mean_file);</div><div class="line"></div><div class="line">    <a class="code" href="../../d3/d63/classcv_1_1Mat.html">cv::Mat</a> img_base = <a class="code" href="../../d4/da8/group__imgcodecs.html#ga288b8b3da0892bd651fce07b3bbd3a56">cv::imread</a>(target_img, -1);</div><div class="line">    <span class="keywordflow">if</span> (img_base.<a class="code" href="../../d3/d63/classcv_1_1Mat.html#abbec3525a852e77998aba034813fded4">empty</a>())</div><div class="line">    {</div><div class="line">        printf(<span class="stringliteral">&quot;could not read reference image %s\n, make sure the path of images are set properly.&quot;</span>, target_img.c_str());</div><div class="line">    }</div><div class="line"></div><div class="line">    std::vector&lt;cv::Mat&gt; img;</div><div class="line">    <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i = 0; i &lt; ref_img.size(); i++)</div><div class="line">    {</div><div class="line">        img.<a class="code" href="../../d3/d63/classcv_1_1Mat.html#af4bd5c2cb936dd363816d867aab22a61">push_back</a>(<a class="code" href="../../d4/da8/group__imgcodecs.html#ga288b8b3da0892bd651fce07b3bbd3a56">cv::imread</a>(ref_img[i], -1));</div><div class="line">        <span class="keywordflow">if</span> (img[i].empty()) {</div><div class="line">          printf(<span class="stringliteral">&quot;could not read reference image %s\n, make sure the path of images are set properly.&quot;</span>, ref_img[i].c_str());</div><div class="line">        }</div><div class="line">    }</div><div class="line">    <a class="code" href="../../d3/d63/classcv_1_1Mat.html">cv::Mat</a> feature_test;</div><div class="line">    descriptor.extract(img_base, feature_test, feature_blob);</div><div class="line">    <span class="keywordflow">if</span> (feature_test.<a class="code" href="../../d3/d63/classcv_1_1Mat.html#abbec3525a852e77998aba034813fded4">empty</a>()) {</div><div class="line">      printf(<span class="stringliteral">&quot;could not extract feature from test image which is read into cv::Mat.&quot;</span>);</div><div class="line">    }</div><div class="line"></div><div class="line">    <a class="code" href="../../d3/d63/classcv_1_1Mat.html">cv::Mat</a> feature_reference;</div><div class="line">    descriptor.extract(img, feature_reference, feature_blob);</div><div class="line">    <span class="keywordflow">if</span> (feature_reference.<a class="code" href="../../d3/d63/classcv_1_1Mat.html#abbec3525a852e77998aba034813fded4">empty</a>()) {</div><div class="line">      printf(<span class="stringliteral">&quot;could not extract feature from reference images which is already stored in vector&lt;cv::Mat&gt;.&quot;</span>);</div><div class="line">    }</div><div class="line"></div><div class="line">    std::vector&lt;float&gt; matches;</div><div class="line">    <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; feature_reference.<a class="code" href="../../d3/d63/classcv_1_1Mat.html#abed816466c45234254d25bc59c31245e">rows</a>; i++)</div><div class="line">    {</div><div class="line">        <a class="code" href="../../d3/d63/classcv_1_1Mat.html">cv::Mat</a> distance = feature_test-feature_reference.<a class="code" href="../../d3/d63/classcv_1_1Mat.html#a4b22e1c23af7a7f2eef8fa478cfa7434">row</a>(i);</div><div class="line">        matches.push_back(<a class="code" href="../../dc/d84/group__core__basic.html#ga4e556cb8ad35a643a1ea66e035711bb9">cv::norm</a>(distance));</div><div class="line">    }</div><div class="line">    <span class="keywordtype">bool</span> pose_pass = <span class="keyword">false</span>;</div><div class="line">    <span class="keywordtype">bool</span> class_pass = <span class="keyword">false</span>;</div><div class="line">    <span class="comment">/* Have comparations on the distance between reference image and 3 other images</span></div><div class="line"><span class="comment">    *distance between closest sample and reference image should be smallest and</span></div><div class="line"><span class="comment">    *distance between sample in another class and reference image should be largest.</span></div><div class="line"><span class="comment">    */</span></div><div class="line">    <span class="keywordflow">if</span> (matches[0] &lt; matches[1] &amp;&amp; matches[0] &lt; matches[2])</div><div class="line">        pose_pass = <span class="keyword">true</span>;</div><div class="line">    <span class="keywordflow">if</span> (matches[1] &lt; matches[2])</div><div class="line">        class_pass = <span class="keyword">true</span>;</div><div class="line">    <span class="keywordflow">if</span> (!pose_pass)</div><div class="line">    {</div><div class="line">        printf(<span class="stringliteral">&quot;\n =========== Model %s ========== \nIs not trained properly that the similar pose could not be tell from a cluster of features.\n&quot;</span>, caffemodel.c_str());</div><div class="line">    }</div><div class="line">    <span class="keywordflow">else</span> <span class="keywordflow">if</span> (!class_pass)</div><div class="line">    {</div><div class="line">        printf(<span class="stringliteral">&quot;\n =========== Model %s ========== \nIs not trained properly that feature from the same class is not discriminant from the one of another class with similar pose.\n&quot;</span>, caffemodel.c_str());</div><div class="line">    }</div><div class="line">    <span class="keywordflow">else</span></div><div class="line">    {</div><div class="line">        printf(<span class="stringliteral">&quot;\n =========== Model %s ========== \nSuits for setting different classes apart and also discriminant on object pose at the same time.\n&quot;</span>, caffemodel.c_str());</div><div class="line">    }</div><div class="line">    <span class="keywordflow">return</span> 0;</div><div class="line">}</div></div><!-- fragment --><h2>Explanation </h2>
<p>Here is the general structure of the program:</p>
<ul>
<li>Sample which is most closest in pose to reference image and also the same class. <div class="fragment"><div class="line">ref_img.push_back(ref_img1);</div></div><!-- fragment --></li>
<li>Sample which is less closest in pose to reference image and also the same class. <div class="fragment"><div class="line">ref_img.push_back(ref_img2);</div></div><!-- fragment --></li>
<li>Sample which is very close in pose to reference image but not the same class. <div class="fragment"><div class="line">ref_img.push_back(ref_img3);</div></div><!-- fragment --></li>
<li>Initialize a net work with Device. <div class="fragment"><div class="line"><a class="code" href="../../d7/d8d/classcv_1_1cnn__3dobj_1_1descriptorExtractor.html">cv::cnn_3dobj::descriptorExtractor</a> descriptor(device, dev_id);</div></div><!-- fragment --></li>
<li>Load net with the caffe trained net work parameter and structure. <div class="fragment"><div class="line"><span class="keywordflow">if</span> (strcmp(mean_file.c_str(), <span class="stringliteral">&quot;no&quot;</span>) == 0)</div><div class="line">    descriptor.loadNet(network_forIMG, caffemodel);</div><div class="line"><span class="keywordflow">else</span></div><div class="line">    descriptor.loadNet(network_forIMG, caffemodel, mean_file);</div></div><!-- fragment --></li>
<li>Have comparations on the distance between reference image and 3 other images distance between closest sample and reference image should be smallest and distance between sample in another class and reference image should be largest. <div class="fragment"><div class="line"><span class="keywordflow">if</span> (matches[0] &lt; matches[1] &amp;&amp; matches[0] &lt; matches[2])</div><div class="line">    pose_pass = <span class="keyword">true</span>;</div><div class="line"><span class="keywordflow">if</span> (matches[1] &lt; matches[2])</div><div class="line">    class_pass = <span class="keyword">true</span>;</div></div><!-- fragment --> <h2>Results </h2>
</li>
</ul>
</div></div><!-- contents -->
<!-- HTML footer for doxygen 1.8.6-->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated on Fri Apr 2 2021 11:36:38 for OpenCV by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="../../doxygen.png" alt="doxygen"/>
</a> 1.8.13
</small></address>
<script type="text/javascript">
//<![CDATA[
addTutorialsButtons();
//]]>
</script>
</body>
</html>
